<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <div id="app"></div>

    <script type="text/javascript" src="../js/react.development.js"></script>
    <script type="text/javascript" src="../js/react-dom.development.js"></script>
    <script type="text/javascript" src="../js/babel.min.js"></script>
    
    <script type="text/babel">
        class Demo extends React.Component {
            myRef = React.createRef()
            showData = ()=>{
                console.log(this.myRef);//{current: input}
                alert(this.myRef.current.value)
            }
            render() {
                return (
                    <div>
                        <input ref={this.myRef} type="text"/>
                        <br/>
                        <br/>
                        <button onClick={this.showData}>点击确认文字</button>
                    </div>
                )
            }
        }

        ReactDOM.render(<Demo/>,document.querySelector('#app'))
    </script>
</body>
</html>
